﻿using DotNetCore.CAP.Messages;
using DotNetCore.CAP.Monitoring;
using DotNetCore.CAP.Persistence;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

namespace DotNetCore.CAP.NoStorage
{
    internal class InMemoryMonitoringApi : IMonitoringApi
    {
        public Task<MediumMessage> GetPublishedMessageAsync(long id)
        {
            return Task.FromResult((MediumMessage)NoStorageStorage.PublishedMessages.Values.First(x => x.DbId == id.ToString(CultureInfo.InvariantCulture)));
        }

        public Task<MediumMessage> GetReceivedMessageAsync(long id)
        {
            return Task.FromResult((MediumMessage)NoStorageStorage.ReceivedMessages.Values.First(x => x.DbId == id.ToString(CultureInfo.InvariantCulture)));
        }

        public StatisticsDto GetStatistics()
        {
            var stats = new StatisticsDto
            {
            };
            return stats;
        }

        public PagedQueryResult<MessageDto> Messages(MessageQueryDto queryDto)
        {
            return new PagedQueryResult<MessageDto>();
        }
        
        public IDictionary<DateTime, int> HourlyFailedJobs(MessageType type)
        {
            return new Dictionary<DateTime, int>();
        }

        public IDictionary<DateTime, int> HourlySucceededJobs(MessageType type)
        {
            return new Dictionary<DateTime, int>();
        }

        public int PublishedFailedCount()
        {
            return 0;
        }

        public int PublishedSucceededCount()
        {
            return 0;
        }

        public int ReceivedFailedCount()
        {
            return 0;
        }

        public int ReceivedSucceededCount()
        {
            return 0;
        }
    }
}
